﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using System.Windows.Shapes;
using System.Windows.Controls;
using WpfApplication2.Helpers;
using System.Windows.Controls.Primitives;


namespace WpfApplication2
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            EventManager.RegisterClassHandler(typeof(DatePicker),
                DatePicker.LoadedEvent,
                new RoutedEventHandler(DatePicker_Loaded));
        }

        void DatePicker_Loaded(object sender, RoutedEventArgs e)
        {
            var dp = sender as DatePicker;
            if (dp == null)
                return;

            var tb = DateCustomizerHelper.GetChildOfType<DatePickerTextBox>(dp);
            if (tb == null)
                return;

            var wm = tb.Template.FindName("PART_Watermark", tb) as ContentControl;
            if (wm == null)
                return;

            wm.Content = "";
        }
    }

    
}
